﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using ProtoBuf.Message;


namespace UI
{
   public class UIActivityUpdate : UIActivityTemplate
   {
       public enum RewardType
       {
           FanliReward = 0,    //更新返利
           SuperExchangeReward = 1,    //超值兑换
           RobRewardReward = 2,    //夺宝福利
           QianxianReward = 3,    //前线福利
           LucklyBoxReward = 4,    //幸运宝箱
           UpdateReward = 5     //更新送礼
       }

       public UIScrollView topscrollow;
       public SimpleGrid topsimpleGrid;
       public ActivityTabItem tabItem;

       public List<GameObject> textures;
       public List<GameObject> persons;

       protected override void PrepareData()
       {
           
           base.PrepareData();
       }

       public override void Show()
       {
           CSActivityList msg = new CSActivityList();
           msg.activityId = this.activityId;
           NetAPI.SendHttp(OpDefine.CSActivityList, msg, GetUpDateActivityCallBack);
           base.Show();
       }

       void SetBgAndPerson(int flag)
       {
           for (int i = 0; i < persons.Count; i++)
           {
               persons[i].gameObject.SetActive(false);
               textures[i].gameObject.SetActive(false);
           }
           persons[flag].gameObject.SetActive(true);
           textures[flag].gameObject.SetActive(true);
       }
       void GetUpDateActivityCallBack(NetWork.Packets.Packet packet,bool IsSuccess)
       {
           foreach (var item in topsimpleGrid.childs)
               Destroy(item);
           topsimpleGrid.childs.Clear();
           if(IsSuccess)
           {
               SCActivityList msg = packet.kBody as SCActivityList;
               foreach(var item in msg.activityList)
               {
                   string[] strs = item.activityId.Split('_');
                   string acId = item.activityId;
                   
                   ActivityTabItem go = Instantiate(tabItem);
                   go.GetComponent<ActivityTabItem>().InitTabItem(acId);
                   go.m_ActivityItemClick = OnTabItemClick;
                   
                   switch( strs[0] )
                   {
                       case "totalLoginFestival":
                           {
                               go.m_ActivityItemClick = OnTabItemClick;
                           }
                           break;
                       default:
                           break;
                   }

               }
               
            
           }
       }

       #region 网络回调
       void FanliRewardCallBack(NetWork.Packets.Packet packet,bool success)
       {

       }

       void SuperExchangeRewardClick(NetWork.Packets.Packet packet, bool success)
       {

       }

       void RobRewardRewardCallBack(NetWork.Packets.Packet packet, bool success)
       {

       }

       void QianxianRewardCallBack(NetWork.Packets.Packet packet, bool success)
       {

       }

       void LucklyBoxRewardCallBack(NetWork.Packets.Packet packet, bool success)
       {

       }
       void UpdateRewardCallBack(NetWork.Packets.Packet packet, bool success)
       {

       }
       #endregion

       #region 顶部tableItem回调
       void OnTabItemClick(int type)
       {
          //SendHttp
          switch((RewardType)type)
          {
              case RewardType.FanliReward:
                  {

                  }
                  break;
              case RewardType.LucklyBoxReward:
                  {

                  }
                  break;
              case RewardType.QianxianReward:
                  { 
                  }
                  break;
              case RewardType.RobRewardReward:
                  {

                  }
                  break;
              case RewardType.SuperExchangeReward:
                  {

                  }
                  break;
              case RewardType.UpdateReward:
                  {

                  }
                  break;
          }
       }
       #endregion
   }
}